function curry(fn: Function): Function {
  if (typeof fn !== "function") {
    throw new TypeError("The param should be a function");
  }
  const fnLength = fn.length;
  return function curryFn(...args: any[]) {
    if (args.length < fnLength) {
      return function () {
        if (arguments.length !== 1) {
          throw new Error("The function just receive an argument");
        }
        const params = args.concat(Array.from(arguments));
        return curryFn.apply(null, params);
      };
    }
    return fn.apply(null, args);
  };
}
export { curry };
